package com.yq.ylmall.cart.api;

import com.yq.ylmall.cart.service.ICartInfoService;
import com.yq.ylmall.dto.cart.CartOrderDto;
import com.yq.ylmall.model.cart.CartInfo;
import com.yq.ylmall.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Project: yourlife
 * @Name: CartInfoApiController
 * @Author: Jack_Li
 * @Date: 2024/6/16 13:17
 */

@RestController
@RequestMapping("/api/cart")
@Slf4j
public class CartInfoApiController {

    @Resource
    private ICartInfoService cartInfoService;

    @PostMapping("/remove")
    public void batchRemove(@RequestBody CartOrderDto cartOrderDto) {
        cartInfoService.batchRemove(cartOrderDto);
    }

    @PostMapping("/save")
    public Result saveCart(@RequestBody List<CartInfo> cartInfos) {
        log.warn("cartInfos:{}", cartInfos);
        cartInfoService.saveCart(cartInfos);
        return Result.ok();
    }

    @GetMapping("/test")
    public Result test() {
        return Result.ok();
    }

}
